package com.example.spring.aop.rest;

import com.example.spring.aop.annotation.RolesControl;
import com.example.spring.aop.service.NeedLogService;
import com.example.spring.aop.service.NormalService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author luowj12
 * @since 2021/6/7 9:30
 */

@Slf4j
@RestController
@RequestMapping("aspect")
public class AspectController {

    @Autowired
    NeedLogService needLogService;

    @Autowired
    NormalService normalService;

    /**
     * 日志拦截检验
     */
    @PostMapping("/log")
    public void log(){

        //needLogService.logMethod("宝能");
        try {
            needLogService.exceptionMethod();
        } catch (Exception e) {
            e.printStackTrace();
        }
        //normalService.someMethod();
    }


    /**
     * 角色权限检验
     */
    @PostMapping("/role")
    @RolesControl("123456")
    public String role(){
        return  "服务正常";
    }
}
